import request from '@/utils/request'

export function getDevices(data) {
  return request({
    url: '/devices',
    method: 'get',
    data
  })
}

export function addDevice(form) {
  var data = JSON.parse(JSON.stringify(form))
  data.value = JSON.stringify(data.value)
  return request({
    url: '/device',
    method: 'post',
    data
  })
}

export function getDevice(id) {
  return request({
    url: '/device/' + id,
    method: 'get'
  })
}

export function deleteDevice(id) {
  return request({
    url: '/device/' + id,
    method: 'delete'
  })
}

export function editDevice(form) {
  var data = JSON.parse(JSON.stringify(form))
  data.value = JSON.stringify(data.value)
  return request({
    url: '/device',
    method: 'put',
    data
  })
}
